﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AutoMapper;
using DevWeb.Biztalk.DeploymentSettings.WebUI.Models;

namespace DevWeb.Biztalk.DeploymentSettings.WebUI.Automapper
{
    public class DeploymentLogViewProfile : Profile
    {
        public const string ViewModel = "DeploymentLogViewProfile";

        public override string ProfileName
        {
            get { return ViewModel; }
        }

        protected override void Configure()
        {
            CreateMaps();
        }

        private static void CreateMaps()
        {
            Mapper.CreateMap<Data.CodeFirst.DeploymentLog, DeploymentLogViewModel>()
                .ForSourceMember(s => s.Id, t => t.Ignore())
                .ForMember(x => x.IntegrationVersion, opt => opt.MapFrom(src => src.IntegrationVersion.Version))
                .ForMember(x => x.Environment, opt => opt.MapFrom(src => src.TargetEnvironment.Name))
                .ForMember(x => x.ProductId, opt => opt.MapFrom(src => src.IntegrationVersion.ProductId.ToString()))
                .ForMember(x => x.IntegrationName, opt => opt.MapFrom(src => src.IntegrationVersion.Integration.Name));
        }
    }
}